
/*
 * @features: 引导启动器
 * @description: 说明
 * @Date: 2021-06-10 13:26:12
 * @Author: judu233(769471424@qq.com)
 * @LastEditTime: 2021-10-06 00:05:53
 * @LastEditors: judu233
 */
import c3d from '../cc';
import { TaskBase } from './task/taskBase';

const { ccclass, property } = c3d._decorator;

@ccclass
export class TaskStart extends c3d.Component {

    @property({ displayName: `开始启动引导` })
    isStartTask = false;

    @property({ displayName: `延时`, min: 0 })
    startTime = 0;

    @property([TaskBase])
    private _taskList: TaskBase[] = [];
    public get taskList(): TaskBase[] {
        if (this._taskList.length == 0) {
            this._taskList = this.node.children.map(child => child.getComponent(TaskBase));
        }
        return this._taskList;
    }
    @property([TaskBase])
    public set taskList(value: TaskBase[]) {
        this._taskList = value;
    }

    start() {
        // if (this.isStartTask)
        //     this.startTask();
    }

    async startTask(taskIndex: number) {
        // await GM.main.guideMgr.ExecutiveGuideUnitData(this.taskList[taskIndex]);
        // for (let task of this.taskList) {
        //     await GM.main.guideMgr.ExecutiveGuideUnitData(task);
        //     await Tool.promise.delay(this.startTime);
        // }

        // log("执行task1")
        // let evtData = { stepIndex: 0 }
        // await this.mgr.ExcuteGuideTask([evtData, evtData], "task1");
        // evtData = { stepIndex: 1 }
        // await this.mgr.ExecutiveGuideUnitStr("task2");
        // log("执行task3")
        // let evtData2 = {
        //     taskFlieName: "task3",
        //     stepIndex: 0
        // }
        // await this.mgr.ExcuteGuideTask([evtData]);
    }
}

